package com.example.mapp;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.*;

import com.example.entity.maintenance.EscalatorHalfMon;
import com.example.entity.maintenance.EscalatorHalfYear;
import com.example.entity.maintenance.EscalatorQuarter;
import com.example.entity.maintenance.EscalatorYear;
import com.example.ext.entity.maintenance.ExtEscalatorHalfMon;
import com.example.mapp.buildSql.MaintMappSql;

/**
 * Created by douyx on 2017/10/29.
 */
@Mapper
public interface EscalatorMapp {
	/**
	 * 新增自动扶梯 人行道半月保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into escalator_half_mon (separateroom_drive_steeringstation,auto_run_function,automatic_oil_level,brake_condition_monitoring_switch,"
			+ "comb_plate_illumination,comb_plate_switch,comb_tread_tooth,electrical_components,emergency_stop_switch,equipment_operation_status,"
			+ "exit_safety_warn,fault_display_board,fixing_of_main,handrail,handrail_baseboard,handrail_run,hmon_brake_mechanism,hmon_reducer_lubricating_oil,"
			+ "hmonmain_drive_chain,inspection_control_device,maintenance_end_date,maintenance_start_date,maintenance_user_sign_id1,maintenance_user_sign_id2,"
			+ "motor_vent,overspeed_monitoring_device,pedal_apron_clearance,pedal_missing_monitoring,pedal_sink_switch,protective_baffle,protective_switch,"
			+ "repair_cover_plate,running_direction_display,step_roller_guiderail,stepchain_tension_switch,"
			+ "type,updown_illumination,updown_protect_railing,elevator_num,maintenance_user_name,maintenance_user_name2," +
			" maintenance_party_id,maintenance_user_id1,maintenance_user_id2," +
			"is_in_time_maint,maintenancen_used_time,change_info,summary,xcfhcs,ldbh,other_photos) " +
			" VALUES (#{separateroomDriveSteeringstation},#{autoRunFunction},#{automaticOilLevel},"
			+ "#{brakeConditionMonitoringSwitch},#{combPlateIllumination},#{combPlateSwitch},#{combTreadTooth},#{electricalComponents},#{emergencyStopSwitch},"
			+ "#{equipmentOperationStatus},#{exitSafetyWarn},#{faultDisplayBoard},#{fixingOfMain},#{handrail},#{handrailBaseboard},#{handrailRun},"
			+ "#{hmonBrakeMechanism},#{hmonReducerLubricatingOil},#{hmonmainDriveChain},#{inspectionControlDevice},#{maintenanceEndDate},#{maintenanceStartDate},"
			+ "#{maintenanceUserSignId1},#{maintenanceUserSignId2},#{motorVent},#{overspeedMonitoringDevice},#{pedalApronClearance},#{pedalMissingMonitoring},"
			+ "#{pedalSinkSwitch},#{protectiveBaffle},#{protectiveSwitch},#{repairCoverPlate},#{runningDirectionDisplay},"
			+ "#{stepRollerGuiderail},#{stepchainTensionSwitch},#{type}," +
			"#{updownIllumination},#{updownProtectRailing},#{elevatorNum}," +
			"#{maintenanceUserName},#{maintenanceUserName2}," +
			"#{maintenancePartyId},#{maintenanceUserId1}," +
			"#{maintenanceUserId2},#{isInTimeMaint},#{maintenancenUsedTime},#{changeInfo},#{summary},#{xcfhcs},#{ldbh},#{otherPhotos}) ")
	@SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id", before = false, resultType = Long.class)
	public Long addEscalatorHalfMon(EscalatorHalfMon escalatorHalfMon) throws Exception;


	/**
	 * 更新自动扶梯
	 * @param map
	 * @return
	 * @throws Exception
	 */
	@Update("update escalator_half_mon set safe_user_sign_id2=#{safeUserSignId2},safe_user_name=#{safeUserName}," +
			"safe_user_sign_time=#{safeUserSignTime},status=#{status},used_party_opt=#{usedPartyOpt} where id=#{elevatoriMonId} ")
	public void updateEscalatorHalfMon(Map<String,Object> map) throws Exception;
	/**
	 * 获取自动扶梯 人行道维保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@SelectProvider(type = MaintMappSql.class, method = "findEscalatorList")
	List<ExtEscalatorHalfMon> findEscalatorList(ExtEscalatorHalfMon escalatorHalfMon) throws Exception;

	@Select(" SELECT * from escalator_half_mon where id = #{id}")
	EscalatorHalfMon queryEscalatorHalfMon(Long id) throws Exception;

	/**
	 * 新增自动扶梯 人行道季度保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into escalator_quarter (antiflood_protection_device,cascade_lubrication,half_mon_id,speed_of_handrail,step_bushings,"
			+ "stepchain_tensioning_device) VALUES (#{antifloodProtectionDevice},#{cascadeLubrication},#{halfMonId},#{speedOfHandrail},"
			+ "#{stepBushings},#{stepchainTensioningDevice}) ")
	@SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id", before = false, resultType = Long.class)
	public Long addEscalatorQuarter(EscalatorQuarter escalatorQuarter) throws Exception;

	@Select(" SELECT * from escalator_quarter where half_mon_id = #{halfMonId}")
	EscalatorQuarter queryEscalatorQuarter(Long halfMonId) throws Exception;

	/**
	 * 新增自动扶梯 人行道半年保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into escalator_half_year (adjust_depth_clearance,armrest_spring_length,auxiliary_brake,brake_lining_thickness,"
			+ "handrail_speed_monitoring,hyear_brake_mechanism,hyear_main_drive_chain,hyear_reducer_lubricating_oil,maindrive_slider,"
			+ "motor_reducer_coupling,noload_run_distance,quarter_id,steppedal_heating_device) VALUES (#{adjustDepthClearance},#{armrestSpringLength},"
			+ "#{auxiliaryBrake},#{brakeLiningThickness},#{handrailSpeedMonitoring},#{hyearBrakeMechanism},#{hyearMainDriveChain},#{hyearReducerLubricatingOil},"
			+ "#{maindriveSlider},#{motorReducerCoupling},#{noloadRunDistance},#{quarterId},#{steppedalHeatingDevice}) ")
	@SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id", before = false, resultType = Long.class)
	public Long addEscalatorHalfYear(EscalatorHalfYear escalatorHalfYear) throws Exception;

	@Select(" SELECT * from escalator_half_year where quarter_id = #{quarterId}")
	EscalatorHalfYear queryEscalatorHalfYear(Long quarterId) throws Exception;

	/**
	 * 新增自动扶梯 人行道年保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into escalator_year (handrail_guideblock_guidewheel,apronplate_butt_joint,apronplate_safety_switch,armrest_inner_flange,"
			+ "cable,electrical_safety_device,half_year_id,handrail_breaking_protective,handrail_wheel,host_speed_detection,inner_momentum,"
			+ "inout_plate_connection,main_contactor) VALUES (#{handrailGuideblockGuidewheel},#{apronplateButtJoint},#{apronplateSafetySwitch},"
			+ "#{armrestInnerFlange},#{cable},#{electricalSafetyDevice},#{halfYearId},#{handrailBreakingProtective},#{handrailWheel},"
			+ "#{hostSpeedDetection},#{innerMomentum},#{inoutPlateConnection},#{mainContactor}) ")
	public Long addEscalatorYear(EscalatorYear escalatorYear) throws Exception;

	@Select(" SELECT * from escalator_year where half_year_id = #{halfYearId}")
	EscalatorYear queryEscalatorYear(Long halfYearId) throws Exception;
}
